<html>
	<head>
     <title>添加数据</title>	
    </head>	
		<body>
			<form method="post">
			<p>
				添加班级：
				<input type="text" name="classname" id="" value="" />
			</p>
            <p>
				专业编号：
				<input type="text" name="majorid" id="" value="" />
			</p>
			<input type="submit" value="提交"/>
			</form>
		</body>
</html>
<?php
$classname=$_POST["classname"];
$majorid=$_POST["majorid"];
if($classname && $majorid){
	//通过PDO连接MYSQL
    $db = new PDO("mysql:host=127.0.0.1;dbname=scholl;charset=utf8","root","123456");
	$sql="insert into banji(classname,majorid)values(:classname,:majorid)";
	$sth=$db->prepare($sql);
	$sth->bindParam(':classname', $classname, PDO::PARAM_STR);
	$sth->bindParam(':majorid', $majorid, PDO::PARAM_INT);
	$result=$sth->execute();
	var_dump($result);
	var_dump($db->lastinsertId());
}
?>